import * as types from './mutation-types'

import walletAPI from "@/api/wallet.js"

export default {
	
	async fetchAssets({commit}){
		const assets = await walletAPI.assets()
		commit(types.UPDATE_ASSETS,assets)
		return assets;
	},
	
	async fetchCashRecord({commit},pageNo){
		const cashRecord = await walletAPI.cashRecord(pageNo)
		commit(types.UPDATE_CASH_RECORD,cashRecord)
		return cashRecord;
	},
	async initWallet({dispatch}){
		await dispatch('fetchAssets')
	},
	async clear({commit}){
		commit(types.UPDATE_ASSETS,{})
	}
}
